package com.ruoyi.wq.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.wq.domain.WqTopicUser;
import com.ruoyi.wq.mapper.WqTopicUserMapper;
import com.ruoyi.wq.service.IWqTopicUserService;

/**
 * 话题关注Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-06-17
 */
@Service
public class WqTopicUserServiceImpl extends ServiceImpl<WqTopicUserMapper, WqTopicUser> implements IWqTopicUserService 
{
    @Autowired
    private WqTopicUserMapper wqTopicUserMapper;

    /**
     * 查询话题关注
     * 
     * @param id 话题关注主键
     * @return 话题关注
     */
    @Override
    public WqTopicUser selectWqTopicUserById(String id)
    {
        return wqTopicUserMapper.selectWqTopicUserById(id);
    }

    /**
     * 查询话题关注列表
     * 
     * @param wqTopicUser 话题关注
     * @return 话题关注
     */
    @Override
    public List<WqTopicUser> selectWqTopicUserList(WqTopicUser wqTopicUser)
    {
        return wqTopicUserMapper.selectWqTopicUserList(wqTopicUser);
    }

    /**
     * 新增话题关注
     * 
     * @param wqTopicUser 话题关注
     * @return 结果
     */
    @Override
    public int insertWqTopicUser(WqTopicUser wqTopicUser)
    {
        wqTopicUser.setCreateTime(DateUtils.getNowDate());
        return wqTopicUserMapper.insertWqTopicUser(wqTopicUser);
    }

    /**
     * 修改话题关注
     * 
     * @param wqTopicUser 话题关注
     * @return 结果
     */
    @Override
    public int updateWqTopicUser(WqTopicUser wqTopicUser)
    {
        wqTopicUser.setUpdateTime(DateUtils.getNowDate());
        return wqTopicUserMapper.updateWqTopicUser(wqTopicUser);
    }

    /**
     * 批量删除话题关注
     * 
     * @param ids 需要删除的话题关注主键
     * @return 结果
     */
    @Override
    public int deleteWqTopicUserByIds(String[] ids)
    {
        return wqTopicUserMapper.deleteWqTopicUserByIds(ids);
    }

    /**
     * 删除话题关注信息
     * 
     * @param id 话题关注主键
     * @return 结果
     */
    @Override
    public int deleteWqTopicUserById(String id)
    {
        return wqTopicUserMapper.deleteWqTopicUserById(id);
    }

	@Override
	public List<WqTopicUser> getFansTopicList() {
		WqTopicUser topicUser = new WqTopicUser();
		topicUser.setUserId(SecurityUtils.getUserId());
		return baseMapper.getFansTopicList(topicUser);
	}

	@Override
	public WqTopicUser getTopicUserByTopicId(String topicId) {
		QueryWrapper<WqTopicUser> qw = new QueryWrapper<>();
		WqTopicUser topicUser = new WqTopicUser();
		topicUser.setUserId(SecurityUtils.getUserId());
		topicUser.setTopicId(topicId);
		qw.setEntity(topicUser);
		return baseMapper.selectOne(qw);
	}

	@Override
	public List<WqTopicUser> getList() {
		QueryWrapper<WqTopicUser> qw = new QueryWrapper<>();
		WqTopicUser topicUser = new WqTopicUser();
		topicUser.setUserId(SecurityUtils.getUserId());
		qw.setEntity(topicUser);
		return baseMapper.selectList(qw);
	}
}
